package com.tgu.home_action.pojo;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;


import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.sql.Timestamp;

@Data
@ApiModel(description = "志愿者信息")
public class VolunteerInformation {
    public interface insert {
    }

    public interface update {
    }

    @ExcelIgnore
    @NotNull(message = "id不能为空", groups = {update.class})
    @ApiModelProperty("ID")
    private Integer id;

    @ApiModelProperty("姓名")
    @ExcelProperty("姓名")
    @NotNull(message = "name不能为空", groups = {insert.class})
    private String name;

    @ApiModelProperty("身份证号")
    @ExcelProperty("身份证号")
    @NotNull(message = "IDCard不能为空", groups = {insert.class})
    @Length(min = 18, max = 18, message = "身份证号必须为18位", groups = {insert.class, update.class})
    private String IDCard;

    @Min(value = 1, message = "sex只能为1或2")
    @Max(value = 2, message = "sex只能为1或2")
    @ApiModelProperty("性别")
    @ExcelIgnore
    private Short sex;

    @ExcelProperty("性别")
    private String gender;

    @ExcelIgnore
    @ApiModelProperty("国家")
    private String country;

    @ExcelProperty("省份")
    @ApiModelProperty("省份")
    private String province;

    @ExcelProperty("城市")
    @ApiModelProperty("城市")
    private String city;

    @ExcelProperty("区")
    @ApiModelProperty("区")
    private String district;

    @ExcelIgnore
    @ApiModelProperty("详细地址")
    private String address;

    @ExcelIgnore
    @ApiModelProperty(value = "注册时间", dataType = "java.sql.Date")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp registerTime;

    @ExcelIgnore
    private Integer volunteerId;

    @ExcelIgnore
    private Volunteer volunteer;

    @ExcelIgnore
    @JsonBackReference("当前页")
    @ApiModelProperty("当前页")
    private Integer pageNo;

    @ExcelIgnore
    @JsonBackReference("每页条数")
    @ApiModelProperty("每页条数")
    private Integer pageSize;

    /**
     * 分页查询前面的数据
     */
    @ExcelIgnore
    @JsonIgnore
    private Integer startSize;

    public VolunteerInformation() {
    }

    public VolunteerInformation(String name, String IDCard) {
        this.name = name;
        this.IDCard = IDCard;
    }

    @Override
    public String toString() {
        return "VolunteerInformation{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", IDCard='" + IDCard + '\'' +
                ", sex=" + sex +
                ", country='" + country + '\'' +
                ", province='" + province + '\'' +
                ", city='" + city + '\'' +
                ", district='" + district + '\'' +
                ", address='" + address + '\'' +
                '}';
    }
}
